/**
 * @author Hang
 * @date 2022/9/23
 * @project AutumnOffer
 * @description
 **/
public class test {
    public static void main(String[] args) {
        Node node1 = new Node(0);
//        node1.next = new Node(2);
//        node1.next.next = new Node(4);
//        node1.next.next.next = new Node(3);
        Node node2 = new Node(0);
//        node2.next = new Node(6);
//        node2.next.next = new Node(4);
        Node node = NodeAdd(node1, node2);
        while(node!=null){
            System.out.println(node.value);
            node = node.next;
        }
    }
    public static Node NodeAdd(Node node1,Node node2){
        int m1 = 0;
        int n1 = 0;
        Node nNode = new Node(0);
        while(node1!=null){
            m1 *= 10;
            m1 += node1.value;
            node1 = node1.next;
        }
        while(node2!=null){
            n1 *= 10;
            n1 += node2.value;
            node2 = node2.next;
        }
        if(n1==0&&m1==0){
            Node tmp = nNode.next;
            nNode.next = new Node(0);
            nNode.next.next = tmp;
            return nNode.next;
        }
        int sum = n1 + m1;
        while(sum != 0){
            Node tmp = nNode.next;
            nNode.next = new Node(sum%10);
            nNode.next.next = tmp;
            sum /= 10;
        }
        return nNode.next;
    }
}
class Node{
    int value;
    Node next;
    public Node(int value){
        this.value = value;
    }
}
